﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows.Forms;

namespace WMR_Data_Logger
{
    internal class About : Form
    {
        private IContainer components;
        private Label labelCompanyName;
        private Label labelCopyright;
        private Label labelProductName;
        private Label labelVersion;
        private Label lb_heading;
        private PictureBox logoPictureBox;
        private Button okButton;
        private TextBox textBoxDescription;

        public About()
        {
            InitializeComponent();
            Text = string.Format("About {0}", AssemblyTitle);
            labelProductName.Text = AssemblyProduct;
            labelVersion.Text = string.Format("Version {0}", AssemblyVersion);
            labelCopyright.Text = AssemblyCopyright;
            labelCompanyName.Text = AssemblyCompany;
            textBoxDescription.Text = AssemblyDescription;
        }

        public string AssemblyCompany
        {
            get
            {
                var customAttributes =
                    Assembly.GetExecutingAssembly().GetCustomAttributes(typeof (AssemblyCompanyAttribute), false);
                if (customAttributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyCompanyAttribute) customAttributes[0]).Company;
            }
        }

        public string AssemblyCopyright
        {
            get
            {
                var customAttributes =
                    Assembly.GetExecutingAssembly().GetCustomAttributes(typeof (AssemblyCopyrightAttribute), false);
                if (customAttributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyCopyrightAttribute) customAttributes[0]).Copyright;
            }
        }

        public string AssemblyDescription
        {
            get
            {
                var customAttributes =
                    Assembly.GetExecutingAssembly().GetCustomAttributes(typeof (AssemblyDescriptionAttribute), false);
                if (customAttributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyDescriptionAttribute) customAttributes[0]).Description;
            }
        }

        public string AssemblyProduct
        {
            get
            {
                var customAttributes =
                    Assembly.GetExecutingAssembly().GetCustomAttributes(typeof (AssemblyProductAttribute), false);
                if (customAttributes.Length == 0)
                {
                    return "";
                }
                return ((AssemblyProductAttribute) customAttributes[0]).Product;
            }
        }

        public string AssemblyTitle
        {
            get
            {
                var customAttributes =
                    Assembly.GetExecutingAssembly().GetCustomAttributes(typeof (AssemblyTitleAttribute), false);
                if (customAttributes.Length > 0)
                {
                    var attribute = (AssemblyTitleAttribute) customAttributes[0];
                    if (attribute.Title != "")
                    {
                        return attribute.Title;
                    }
                }
                return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
            }
        }

        public string AssemblyVersion
        {
            get { return Assembly.GetExecutingAssembly().GetName().Version.ToString(); }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            var manager = new ComponentResourceManager(typeof (About));
            logoPictureBox = new PictureBox();
            labelProductName = new Label();
            labelVersion = new Label();
            labelCopyright = new Label();
            labelCompanyName = new Label();
            textBoxDescription = new TextBox();
            okButton = new Button();
            lb_heading = new Label();
            ((ISupportInitialize) logoPictureBox).BeginInit();
            base.SuspendLayout();
            logoPictureBox.Location = new Point(12, 12);
            logoPictureBox.Name = "logoPictureBox";
            logoPictureBox.Size = new Size(130, 0x5f);
            logoPictureBox.SizeMode = PictureBoxSizeMode.AutoSize;
            logoPictureBox.TabIndex = 0x1a;
            logoPictureBox.TabStop = false;
            labelProductName.AutoSize = true;
            labelProductName.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Bold, GraphicsUnit.Point, 0);
            labelProductName.ForeColor = Color.Black;
            labelProductName.Location = new Point(0xa2, 12);
            labelProductName.Margin = new Padding(6, 0, 3, 0);
            labelProductName.MaximumSize = new Size(0, 0x11);
            labelProductName.Name = "labelProductName";
            labelProductName.Size = new Size(0x57, 13);
            labelProductName.TabIndex = 0x1b;
            labelProductName.Text = "Product Name";
            labelProductName.TextAlign = ContentAlignment.MiddleLeft;
            labelVersion.AutoSize = true;
            labelVersion.ForeColor = Color.Black;
            labelVersion.Location = new Point(0xa2, 0x1d);
            labelVersion.Margin = new Padding(6, 0, 3, 0);
            labelVersion.MaximumSize = new Size(0, 0x11);
            labelVersion.Name = "labelVersion";
            labelVersion.Size = new Size(0x2a, 13);
            labelVersion.TabIndex = 0x19;
            labelVersion.Text = "Version";
            labelVersion.TextAlign = ContentAlignment.MiddleLeft;
            labelCopyright.AutoSize = true;
            labelCopyright.Location = new Point(0xa2, 0x2e);
            labelCopyright.Margin = new Padding(6, 0, 3, 0);
            labelCopyright.MaximumSize = new Size(0, 0x11);
            labelCopyright.Name = "labelCopyright";
            labelCopyright.Size = new Size(0x33, 13);
            labelCopyright.TabIndex = 0x1c;
            labelCopyright.Text = "Copyright";
            labelCopyright.TextAlign = ContentAlignment.MiddleLeft;
            labelCompanyName.AutoSize = true;
            labelCompanyName.Location = new Point(0xa2, 0x3f);
            labelCompanyName.Margin = new Padding(6, 0, 3, 0);
            labelCompanyName.MaximumSize = new Size(0, 0x11);
            labelCompanyName.Name = "labelCompanyName";
            labelCompanyName.Size = new Size(0x52, 13);
            labelCompanyName.TabIndex = 0x1d;
            labelCompanyName.Text = "Company Name";
            labelCompanyName.TextAlign = ContentAlignment.MiddleLeft;
            textBoxDescription.BorderStyle = BorderStyle.None;
            textBoxDescription.ForeColor = Color.Black;
            textBoxDescription.Location = new Point(0xa5, 80);
            textBoxDescription.Margin = new Padding(6, 3, 3, 3);
            textBoxDescription.Multiline = true;
            textBoxDescription.Name = "textBoxDescription";
            textBoxDescription.ReadOnly = true;
            textBoxDescription.ScrollBars = ScrollBars.Both;
            textBoxDescription.Size = new Size(240, 0x22);
            textBoxDescription.TabIndex = 30;
            textBoxDescription.TabStop = false;
            textBoxDescription.Text = "Description";
            okButton.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            okButton.DialogResult = DialogResult.Cancel;
            okButton.Location = new Point(330, 120);
            okButton.Name = "okButton";
            okButton.Size = new Size(0x4b, 0x17);
            okButton.TabIndex = 0x1f;
            okButton.Text = "&OK";
            okButton.Click += okButton_Click;
            lb_heading.AutoSize = true;
            lb_heading.Font = new Font("Arial Narrow", 15.75f, FontStyle.Bold, GraphicsUnit.Point, 0);
            lb_heading.ForeColor = Color.DimGray;
            lb_heading.Location = new Point(0x1d, 0x74);
            lb_heading.Name = "lb_heading";
            lb_heading.Size = new Size(0x55, 0x19);
            lb_heading.TabIndex = 0x20;
            lb_heading.Text = "WMR200";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x199, 150);
            base.Controls.Add(labelProductName);
            base.Controls.Add(labelVersion);
            base.Controls.Add(labelCopyright);
            base.Controls.Add(labelCompanyName);
            base.Controls.Add(textBoxDescription);
            base.Controls.Add(lb_heading);
            base.Controls.Add(logoPictureBox);
            base.Controls.Add(okButton);
            base.FormBorderStyle = FormBorderStyle.FixedDialog;
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "About";
            base.Padding = new Padding(9);
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.CenterScreen;
            Text = "About WMR200 Data Logger Sniffer";
            base.TopMost = true;
            ((ISupportInitialize) logoPictureBox).EndInit();
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            base.Close();
        }
    }
}